package com.example.myweather.util;

import java.util.concurrent.TimeUnit;

import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
//这个对象是用来进行网络申请的
public class HttpUtil {
    //静态方法
    public static void sendOkHttpRequest(String address, Callback callBack){
        OkHttpClient client = new OkHttpClient().newBuilder().
                readTimeout(60000, TimeUnit.MILLISECONDS)
                .connectTimeout(60000,TimeUnit.MILLISECONDS).build();//这里要长时间去等待获取数据，所以将时间延长一点
        Request request = new Request.Builder().url(address).build();
        client.newCall(request).enqueue(callBack);
    }
}
